package com.zego.wawaji.ui.bean.user;

import android.os.Parcel;

import org.json.JSONObject;

/**
 * 用户基本信息
 */
public class UserInfo extends UserBasic {
    private String avatarBig;
    private int avatar_status;   // 头像状态 0为未审核，1为通过，2为拒绝,3未上传 4 好 5 很好

    private int wwCoinCz;  // 充值的娃娃币
    private int wwCoinZs;  // 赠送的娃娃币
    private int wwNum;     // 拥有的娃娃数
    private int wwSendNum;  // 已发货的娃娃数
    private int wwPoint;   // 用户积分

    private int totalwwCoin; // 本地维护，不在解析列表中

    public void parseBasic(String s) {
        super.parseJson(s);
    }

    @Override
    public void parseJson(String s) {
        JSONObject detailObject = getJsonObject(s);
        this.setUid(detailObject.optLong("Id"));
        this.setAvatarBig(detailObject.optString("AvatarBig"));
        this.setAvatar_status(detailObject.optInt("AvatarStatus"));

        this.setWwCoinCz(detailObject.optInt("WwCoinCz"));
        this.setWwCoinZs(detailObject.optInt("WwCoinZs"));
        this.setWwNum(detailObject.optInt("WwNum"));
        this.setWwSendNum(detailObject.optInt("WwSendNum"));
        this.setWwPoint(detailObject.optInt("WwPoint"));

        this.setTotalWwCoin(getWwCoinCz() + getWwCoinZs());
    }

    /**
     * 获取总娃娃币数量
     */
    public int getTotalWwCoin() {
        return totalwwCoin;
    }

    public void setTotalWwCoin(int wwCoin) {
        this.totalwwCoin = wwCoin;
    }

    public int getWwCoinCz() {
        return wwCoinCz;
    }

    public void setWwCoinCz(int wwCoinCz) {
        this.wwCoinCz = wwCoinCz;
    }

    public int getWwCoinZs() {
        return wwCoinZs;
    }

    public void setWwCoinZs(int wwCoinZs) {
        this.wwCoinZs = wwCoinZs;
    }

    public int getWwNum() {
        return wwNum;
    }

    public void setWwNum(int wwNum) {
        this.wwNum = wwNum;
    }

    public int getWwSendNum() {
        return wwSendNum;
    }

    public void setWwSendNum(int wwSendNum) {
        this.wwSendNum = wwSendNum;
    }

    public int getWwPoint() {
        return wwPoint;
    }

    public void setWwPoint(int wwPoint) {
        this.wwPoint = wwPoint;
    }

    public int getAvatar_status() {
        return avatar_status;
    }

    public void setAvatar_status(int avatar_status) {
        this.avatar_status = avatar_status;
    }

    public String getAvatarBig() {
        return avatarBig;
    }

    public void setAvatarBig(String avatarBig) {
        this.avatarBig = avatarBig;
    }

    public UserInfo() {
    }

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        super.writeToParcel(dest, flags);
        dest.writeString(this.avatarBig);
        dest.writeInt(this.avatar_status);
        dest.writeInt(this.wwCoinCz);
        dest.writeInt(this.wwCoinZs);
        dest.writeInt(this.wwNum);
        dest.writeInt(this.wwSendNum);
        dest.writeInt(this.wwPoint);
        dest.writeInt(this.totalwwCoin);
    }

    protected UserInfo(Parcel in) {
        super(in);
        this.avatarBig = in.readString();
        this.avatar_status = in.readInt();
        this.wwCoinCz = in.readInt();
        this.wwCoinZs = in.readInt();
        this.wwNum = in.readInt();
        this.wwSendNum = in.readInt();
        this.wwPoint = in.readInt();
        this.totalwwCoin = in.readInt();
    }

    public static final Creator<UserInfo> CREATOR = new Creator<UserInfo>() {
        @Override
        public UserInfo createFromParcel(Parcel source) {
            return new UserInfo(source);
        }

        @Override
        public UserInfo[] newArray(int size) {
            return new UserInfo[size];
        }
    };
}
